
#ifndef ICOMMON_HPP
#define ICOMMON_HPP

// Auxiliary functions for qtwi core implementations //

// QI widget objects

#define QI_WIDGET(QLF, QWG) \
	public:\
	QLF void show() {\
		QWG::show();\
	}\
	QLF void hide() {\
		QWG::hide();\
	}\
	QLF void refresh() {\
		QWG::update();\
	}\
	QLF void enable() {\
		QWG::setEnabled(true);\
	}\
	QLF void disable() {\
		QWG::setEnabled(false);\
	}\
	QLF void resize(int w, int h) {\
		QWG::resize(w, h);\
	}\
	QLF void move(int x, int y) {\
		QWG::move(x, y);\
	}\
	QLF int getWidth() const {\
		return QWG::width();\
	}\
	QLF void setBgColor(IColor::Color color) {\
		QWG::setStyleSheet("background-color: " + color_mappings[color]);\
	}\
	QLF void setFgColor(IColor::Color color) {\
		QWG::setStyleSheet("color: " + color_mappings[color]);\
	}

// For adding QIWidgets to IRadiouGroup

#define rtti_qiradiogroup_parent(QCLASS) \
	if(typeid(*parent) == typeid(QIRadioGroup))\
		QCLASS::setParent(dynamic_cast<QGroupBox*>(parent));	\
	else\
		QCLASS::setParent(parent);

// TIWidget self reference to its TN_WIDGET*

#define THIS_TWG (*(*(TIWidget*)this))

// XIObject's constructors in iiwidgets.hpp

#define qiobj_constructor(ELMNT) \
	QI##ELMNT(QIWidget *parent, const QString &label, int x, int y) : Q##ELMNT(label, parent) { Q##ELMNT::move(x, y); }

#define tiobj_constructor(ELMNT, TNW_NAME) \
	TI##ELMNT(const char *label, TIWidget *parent, int x, int y) {\
		Create(__FILE__, label, TNW_NAME, **parent, x, y, TN_CAPTION, label, TN_END);\
	}

#endif
